<div role="tabpanel" class="tab-pane config-section" id="email">
	<form method="POST" autocomplete="off" class="w-100">
		<h5>邮件内容</h5>
		<small class="form-text text-muted">
			自定义CTFd邮件内容 <a href="https://docs.ctfd.io/docs/settings/emails/#email-content" target="_blank">可使用预定义变量</a> 
		</small>
		<ul class="nav nav-tabs mt-3" role="tablist">
			<li class="nav-item active">
				<a class="nav-link active" href="#confirmation-email-tab" role="tab" data-toggle="tab">
					确认信息
				</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#account-details-email-tab" role="tab" data-toggle="tab">账户详情</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#password-reset-email-tab" role="tab" data-toggle="tab">密码重置</a>
			</li>
		</ul>

		<div class="tab-content">
			<div role="tabpanel" class="tab-pane active" id="confirmation-email-tab">
				<div class="form-group">
					<label class="pt-3">
						用户注册<br>
						<small class="form-text text-muted">
							用户注册完毕后会发送给用户一封邮件。
						</small>
					</label>
					<div>
						<label>
							主题
						</label>
						<input class="form-control" id='successful_registration_email_subject' name='successful_registration_email_subject' type='text'
							value="{{ successful_registration_email_subject or ''}}">
						<label>
							内容
						</label>
						<textarea class="form-control" type="text" id="successful_registration_email_body" name="successful_registration_email_body"
							rows="5">{{ successful_registration_email_body or '' }}</textarea>
					</div>
				</div>

				<div class="form-group">
					<label class="pt-3">
						用户确认<br>
						<small class="form-text text-muted">
							发送给用户一封确认账户邮件。
						</small>
					</label>
					<div>
						<label>
							主题
						</label>
						<input class="form-control" id='verification_email_subject' name='verification_email_subject' type='text' value="{{ verification_email_subject or ''}}">
						<label>
							内容
						</label>
						<textarea class="form-control" type="text" id="verification_email_body" name="verification_email_body"
							rows="5">{{ verification_email_body or '' }}</textarea>
					</div>
				</div>
			</div>
			<div role="tabpanel" class="tab-pane" id="account-details-email-tab">
				<div class="form-group">
					<label class="pt-3">
						新用户详情<br>
						<small class="form-text text-muted">
							发送给用户一封初始账户信息的邮件(由管理员创建)。
						</small>
					</label>
					<div>
						<label>
							主题
						</label>
						<input class="form-control" id='user_creation_email_subject' name='user_creation_email_subject' type='text'
							value="{{ user_creation_email_subject or ''}}">
						<label>
							内容
						</label>
						<textarea class="form-control" type="text" id="user_creation_email_body" name="user_creation_email_body"
							rows="5">{{ user_creation_email_body or '' }}</textarea>
					</div>
				</div>
			</div>
			<div role="tabpanel" class="tab-pane" id="password-reset-email-tab">
				<div class="form-group">
					<label class="pt-3">
						密码重置请求<br>
						<small class="form-text text-muted">
							当用户选择重置密码的时候发送一封邮件给用户。
						</small>
					</label>
					<div>
						<label>
							主题
						</label>
						<input class="form-control" id='password_reset_subject' name='password_reset_subject' type='text'
							value="{{ password_reset_subject or ''}}">
						<label>
							内容
						</label>
						<textarea class="form-control" type="text" id="password_reset_body" name="password_reset_body"
							rows="5">{{ password_reset_body or '' }}</textarea>
					</div>
				</div>

				<div class="form-group">
					<label class="pt-3">
						密码重置确认<br>
						<small class="form-text text-muted">
							用户成功重置密码后会发送一封电子邮件给用户。
						</small>
					</label>
					<div>
						<label>
							主题
						</label>
						<input class="form-control" id='password_change_alert_subject' name='password_change_alert_subject' type='text'
							value="{{ password_change_alert_subject or ''}}">
						<label>
							内容
						</label>
						<textarea class="form-control" type="text" id="password_change_alert_body" name="password_change_alert_body"
							rows="5">{{ password_change_alert_body or '' }}</textarea>
					</div>
				</div>
			</div>
		</div>

		<hr class="my-5">

		<h5>邮件服务器</h5>
		<small class="form-text text-muted">
			更改CTFd用于发送邮件的邮件服务器。
		</small>
		<ul class="nav nav-tabs my-3" role="tablist">
			<li class="nav-item active">
				<a class="nav-link active" href="#mailserver" role="tab" data-toggle="tab">邮件服务</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#mailgun" role="tab" data-toggle="tab">Mailgun</a>
			</li>
		</ul>

		<div class="form-group">
			<label>
				寄件地址<br>
				<small class="form-text text-muted">
					用于发送邮件的电子邮件地址
				</small>
			</label>
			<input class="form-control" id='mailfrom_addr' name='mailfrom_addr' type='text' {% if mailfrom_addr is defined and mailfrom_addr != None %}value="{{ mailfrom_addr }}"{% endif %}>
		</div>

		<div class="tab-content">
			<div role="tabpanel" class="tab-pane active" id="mailserver">

				<div class="form-group">
					<label>
						邮件服务器地址<br>
						<small class="form-text text-muted">
							邮件服务器地址
						</small>
					</label>
					<input class="form-control" id='mail_server' name='mail_server' type='text'
						   {% if mail_server is defined and mail_server != None %}value="{{ mail_server }}"{% endif %}>
				</div>

				<div class="form-group">
					<label>
						邮件服务器端口<br>
						<small class="form-text text-muted">
							邮件服务器端口
						</small>
					</label>
					<input class="form-control" id='mail_port' name='mail_port' type='text'
						   {% if mail_port is defined and mail_port != None %}value="{{ mail_port }}"{% endif %}>
				</div>
				<div class="form-check">
					<label>
						<input id="mail_useauth" name="mail_useauth" type="checkbox"
							   {% if mail_useauth %}checked{% endif %}>
						使用邮件服务器用户名和密码
					</label>
				</div>
				<div id="mail_username_password">
					<div class="form-group">
						<label>
							用户名<br>
							<small class="form-text text-muted">
								邮件服务器账户用户名
							</small>
						</label>
						{% if mail_username is defined and mail_username != None %}
							<label>
								<sup class="form-text text-muted">已设置邮件服务器用户名</sup>
							</label>
						{% endif %}
						<input class="form-control" id='mail_username' name='mail_username' autocomplete='off' type='text'>
					</div>
					<div class="form-group">
						<label for="mail_password">
							密码<br>
							<small class="form-text text-muted">
								邮件服务器账户密码
							</small>
						</label>
						{% if mail_password is defined and mail_password != None %}
							<label>
								<sup class="form-text text-muted">已设置邮件服务器密码</sup>
							</label>
						{% endif %}
						<input class="form-control" id='mail_password' name='mail_password' autocomplete='off' type='password'>
					</div>
					<sup>取消选中设置并更新以删除用户名和密码。</sup>
					<br>
					<br>
				</div>
				<div class="form-check">
					<label>
						<input id="mail_ssl" name="mail_ssl" type="checkbox" {% if mail_ssl %}checked{% endif %}>
						SSL
					</label>
				</div>
				<div class="form-check">
					<label>
						<input id="mail_tls" name="mail_tls" type="checkbox" {% if mail_tls %}checked{% endif %}>
						TLS
					</label>
				</div>
			</div>
			<div role="tabpanel" class="tab-pane" id="mailgun">
				<div class="alert alert-warning" role="alert">
					Mailgun集成已弃用! 请检查您的Mailgun账户来获取SMTP凭证.
				</div>
				<div class="form-group">
					<label>
						Mailgun API Base URL<br>
						<small class="form-text text-muted">
							Mailgun API Base URL
						</small>
					</label>
					<input class="form-control" id='mailgun_base_url' name='mailgun_base_url' type='text'
						   {% if mailgun_base_url is defined and mailgun_base_url != None %}value="{{ mailgun_base_url }}"{% endif %}>
				</div>
				<div class="form-group">
					<label>
						Mailgun API Key<br>
						<small class="form-text text-muted">
							Mailgun API Key
						</small>
					</label>
					<input class="form-control" id='mailgun_api_key' name='mailgun_api_key' type='text'
						   {% if mailgun_api_key is defined and mailgun_api_key != None %}value="{{ mailgun_api_key }}"{% endif %}>
				</div>
			</div>
		</div>
		<button type="submit" class="btn btn-md btn-primary float-right">Update</button>
	</form>
</div>